﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />
<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/ecommerce">电商管理</a></li>
          <li class="active">课程排期</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>线下课程&nbsp;-&nbsp;团课</span></h2>
              <div class="pull-right">
                <c:choose>
                  <c:when test="${not empty currentPrincipal.site}">
                    <span class="current-branchCode">${currentPrincipal.site.name}</span>
                  </c:when>
                  <c:otherwise>
                    <select name="site">
                      <option value="">所有门店</option>
                      <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                        <option value="${site.id}" ${site.id == param.site ? 'selected' : ''}>${site.name}</option>
                      </c:forEach>
                    </select>
                  </c:otherwise>
                </c:choose>
              </div>
            </div>
            <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
              <ul class="nav nav-pills x-breadcrumb-nav">
                <li class="pull-left ${status == 'arranging' ? 'active' : ''}"><a href="${ctx.host}/group-rounds?status=arranging&${queryString}">待排课学员</a></li>
                <li class="pull-left ${status == 'prepare' ? 'active' : ''}"><a href="${ctx.host}/group-rounds?status=prepare&${queryString}">筹备中</a></li>
                <li class="pull-left ${status == 'ready' ? 'active' : ''}"><a href="${ctx.host}/group-rounds?status=ready&${queryString}">上课中</a></li>
                <li class="pull-left ${status == 'finish' ? 'active' : ''}"><a href="${ctx.host}/group-rounds?status=finish&${queryString}">已完成</a></li>
                <li class="pull-left ${status == 'cancel' ? 'active' : ''}"><a href="${ctx.host}/group-rounds?status=cancel&${queryString}">已取消</a></li>
              </ul>
            </div>
          </div>
          
          <c:if test="${status == 'arranging'}">
            <div class="x-toolbar-wrapper clearfix" style="margin-top: 15px;">
              <div class="btn-group pull-right">
                 <a href="${ctx.host}/group-rounds/create" class="btn btn-default x-btn btn-shadow btn-shadow-default" data-toggle="modal" data-target="#group-round-create">
                   <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;新建团课
                 </a>
              </div>
            </div>
          </c:if>
          
          <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
            <thead>
              <tr>
                <c:choose>
                <c:when test="${status != 'arranging'}">
                  <th>团课编号</th>
                  <th>操房</th>
                  <th>开课时间</th>
                  <th>门店</th>
                  <th>课程周期</th>
                  <th>课时</th>
                  <th>状态</th>
                  <th class="text-center">操作</th>
                </c:when>
                <c:otherwise>
                  <th>姓名</th>
                  <th>电话</th>
                  <th>课程名称</th>
                  <th>场地名称</th>
                </c:otherwise>
                </c:choose>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="courseRound" items="${courseRounds}">
                <tr>
                  <c:choose>
                    <c:when test="${status != 'arranging'}">
                      <td>${courseRound.groupAttr.description}</td>
                      <td>${courseRound.groupAttr.gym}</td>
                      <td>${courseRound.groupAttr.openDescription}</td>
                      <td>${courseRound.site.name}</td>
                      <td>${courseRound.course.weeks}</td>
                      <td>${courseRound.course.hours}</td>
                      <td>${status == 'arranging' ? '待排课' : courseRound.courseStatus.description}</td>
                      <td class="text-center">
                        <c:if test="${courseRound.courseStatus.prepare}">
                          <a href="${ctx.host}/group-rounds/${courseRound.code}/
                          " data-toggle="modal" data-target="#group-round-arrange">排期</a>&nbsp;&nbsp;
                        </c:if>
                        <a href="${ctx.host}/group-rounds/${courseRound.code}">详情</a>
                      </td>
                  </c:when>
                  <c:otherwise>
                    <td>${courseRound.student.name}</td>
                    <td>${courseRound.student.mobile}</td>
                    <td>${courseRound.course.name}</td>
                    <td>${courseRound.site.name}</td>
                  </c:otherwise>
                  </c:choose>
                </tr>
              </c:forEach>
            </tbody>
          </table>

          <jsp:include page="/WEB-INF/include/page.jsp">
            <jsp:param name="url" value="group-rounds" />
            <jsp:param name="queryString" value="${queryString}" />
          </jsp:include>

        </div>
      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/course/group-round-list.js">
    <script type="text/javascript">
      require(['page/course/group-round-list'], function(page) {
        page.init({status: '${status}'})
      })
    </script>
  </d:resource>

</body>

</html>
